﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoiffeurProject.DBMS.Entities;
using CoiffeurProject.DBMS.Utils;

namespace CoiffeurProject.DBMS.Tables
{
    public class Employees
    {
        Database database;

        List<Employee> employees;

        public Employees(String[] datas, Database database)
        {
            this.database = database;

            employees = new List<Employee>();

            for (int i = 0; i < datas.Length; i++)
            {
                var entries = datas[i].Split(new char[] { Constants.Separator });

                employees.Add(new Employee(int.Parse(entries[0]), entries[1], entries[2], entries[3], entries[4], entries[5],
                    entries[6], entries[7], DataConversion.StringToDate(entries[8])));
            }

            Customer.CURRENT_ID = employees.Count > 0 ? employees.Max(c => c.Id) : 0;
        }

        public String[] ToStrings()
        {
            String[] s = new String[employees.Count];

            for (int i = 0; i < employees.Count; i++)
                s[i] = employees[i].ToString();

            return s;
        }

        public List<Employee> List
        {
            get { return employees; }
            set { employees = value; }
        }
    }
}
